package cn.edu.scau.cmi.xiaozhenlin.spring;

import org.springframework.context.ApplicationContext;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class SpringCtrl {

	@FXML
	private Label lblName;

	@FXML
	private Label lblTutor;

	@FXML
	private Label lblGender;

	@FXML
	private TextField tfId;

	@FXML
	void onSearchClick(ActionEvent event) {
		ApplicationContext con = ApplicationContextUtil.getApplicationContext();
		try {
			Student student = (Student) con.getBean(tfId.getText());
			lblName.setText(student.getName());
			lblTutor.setText(student.getTutor().getName());
			lblGender.setText(student.getGendar());
		} catch (Exception e) {
			lblName.setText("没有id对应的学生");
		}
	}

}